﻿using System.Collections.Generic;

namespace SHomeWorkshop.LunarPresentation
{
    public class TextCmdList
    {
        private List<string> cmdStrings = new List<string>();

        public void AddCmd(string newCmdString)
        {
            cmdStrings.Add(newCmdString);
            this.index = this.cmdStrings.Count;
        }

        private string curCmdString;

        public string CurCmdString
        {
            get { return curCmdString; }
        }

        public bool IsNextEnable
        {
            get
            {
                return (this.index >= 0 && this.index < this.cmdStrings.Count - 1);
            }
        }

        public void Next()
        {
            this.index += 1;
            if (this.index < this.cmdStrings.Count)
            {
                this.curCmdString = this.cmdStrings[index];
            }
            else
            {
                this.curCmdString = null;
            }
        }

        public bool IsPreviewEnable
        {
            get
            {
                return (this.index > 0 && this.index <= this.cmdStrings.Count);
            }
        }

        public void Preview()
        {
            this.index -= 1;
            if (this.index >= 0)
            {
                this.curCmdString = this.cmdStrings[index];
            }
            else
            {
                this.curCmdString = null;
            }
        }

        public void ResetIndex()
        {
            this.index = this.cmdStrings.Count;
        }

        private int index;

        /// <summary>
        /// “命令模式：”——值就是这几个字符。
        /// </summary>
        public static string defPreFixString = "命令模式：";
    }
}
